### STUDY 3 ANALYSIS AND VISUALIZATIONS

metoo3_long <- read.csv("study3_replication_analysis.csv")

library(miceadds)
library(ggplot2)
library(sjPlot)
library(ggpubr)
library(patchwork)

### S10: Numerical results: Study 3 -- Table S10.1 and S10.2

metoo3_long2 <- metoo3_long %>% filter(treatment != "control" ) %>% filter(treatment != "apology only") %>% filter(treatment != "denial only")
metoo3_long2$treatment <- factor(metoo3_long2$treatment, levels=c("evidence only", "apology then evidence", "denial then evidence",
                                                                  "evidence then apology", "evidence then denial"))

## Table S10.1

m1 <- lm(resign ~ treatment + resign_base, data = metoo3_long2)
summary(m1)
m1_robust <- lm.cluster(resign ~ treatment + resign_base, cluster="ResponseId", data = metoo3_long2)
summary(m1_robust)


## Table S10.2

m2 <- lm(likely ~ treatment + likely_base, data = metoo3_long2)
summary(m2)
m2_robust <- lm.cluster(likely ~ treatment + likely_base, cluster="ResponseId", data = metoo3_long2)
summary(m2_robust)


## S11: Study 3 Replication of Study 1 and Study 2 -- Table S11.1 and Table S11.2

metoo3_long3 <- metoo3_long %>% filter(treatment == "control" | treatment == "apology only" | treatment == "denial only")
metoo3_long3$treatment <- factor(metoo3_long3$treatment, levels=c("control", "apology only", "denial only"))

## Table S11.1

m3 <- lm(resign ~ treatment, data=metoo3_long3)
summary(m3)

m3_robust <- lm.cluster(resign ~ treatment, cluster="ResponseId", data=metoo3_long3)
summary(m3_robust)

## Table S11.2

m4 <- lm(likely ~ treatment, data=metoo3_long3)
summary(m4)
m4_robust <- lm.cluster(likely ~ treatment, cluster="ResponseId", data=metoo3_long3)
summary(m4_robust)


### MAIN TEXT Figure 3

set_theme(base = theme_classic(), #To remove the background color and the grids  #To change the font typ
          axis.title.size = 1,  #To change axis title size
          axis.textsize.x = 1,  #To change x axis text size
          axis.textsize.y = 1)

fig3_likely <- plot_models(m2, show.values = TRUE,
                           title = "Belief in Allegation", rm.terms = c("likely_base"),
                           vline.color = "grey80",
                           axis.labels = c("Evidence, then Denial", "Evidence, then Apology","Denial, then Evidence", "Apology, then Evidence"),
                           dot.size=4, line.size=1.3, value.size = 4, colors= "gs", show.legend = FALSE, axis.lim = c(-25,10),
                           robust=TRUE) + 
  theme(text = element_text(size=12))
fig3_likely


fig3_resign <- plot_models(m1, show.values = TRUE,
                           title = "Resignation Support", rm.terms = c("resign_base"),
                           vline.color = "grey80",
                           axis.labels = c("", "", "", "", "", ""),
                           dot.size=4, line.size=1.3, value.size = 4, colors= "gs", show.legend = FALSE, axis.lim = c(-20,1),
                           robust=TRUE) + 
  theme(text = element_text(size=12))
fig3_resign

plot_fig3 <- fig3_likely | fig3_resign
plot_fig3

## ggsave("fig3.png", width = 8, height = 4, dpi = 600)  
